<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:t="http://www.w3.org/1999/xhtml">
<head th:replace="components/easyui/easyui-list :: head('新闻', 'easyui,upload,ueditor')">
<body>
<form id="form_edit">
                <div>
                    <input class="easyui-numberbox" id="edit_id" name="id" data-options="label:'id:', width:300, required:true" th:value="${newsInfo.id}">
                </div>
                <div>
                    <input class="easyui-textbox" id="edit_title" name="title" data-options="label:'标题:', width:300, required:true" th:value="${newsInfo.title}">
                </div>
                <div>
                    <t:dict class="easyui-combobox" id="edit_status" name="status" dict-name="news_status" data-options="label:'状态:', width:300, multiple:false"></t:dict>
                </div>
                <div>
                    <label style="width: 80px;float:left;">新闻内容:</label>
                    <div id="edit_content_editor" type="text/plain" style="width:80%;height:400px;float:left;"></div>
                    <div style="clear:both"></div>
                </div>
                <div>
                    <label style="width: 80px;float:left;">缩略图:</label>
                    <div th:replace="components/toolbar :: file-upload (idVal='edit_imageUrl',nameVal='imageUrl')" style="width:94%;float:left;"></div>
                    <div style="clear:both"></div>
                </div>
                <div>
                    <input class="easyui-datetimebox" id="edit_publishDate" name="publishDate" data-options="label:'发布时间:', width:300, required:true" th:value="${newsInfo.publishDate}">
                </div>
                <div>
                    <input class="easyui-textbox" id="edit_tags" name="tags" data-options="label:'标签:', width:300, required:true" th:value="${newsInfo.tags}">
                </div>
                <div>
                    <t:dict class="easyui-combobox" id="edit_newsType" name="newsType" dict-name="news_status" data-options="label:'新闻类型:', width:300, multiple:false"></t:dict>
                </div>
    <div style="text-align:center;pediting:5px 0">
        <a href="javascript:void(0)" class="button button-rounded button-small button-primary" onclick="edit()" th:text="#{ok}"></a>
        <a href="javascript:void(0)" class="button button-rounded button-small" onclick="clearForm()" th:text="#{cancel}"></a>
    </div>
</form>
<div id="dlg" class="easyui-dialog" data-options="title:'图片信息',closed:true" style="width:480px;height:480px;pediting:10px"></div>
<div id="window_content" class="easyui-window" title="内容详情" data-options="modal:true,closed:true,collapsible:false" style="width:720px;height:480px;pediting:10px;"></div>
<div th:replace="components/easyui/easyui-list :: js('easyui,upload,ueditor')"></div>
<script th:inline="javascript">
    /*<![CDATA[*/
    $(function () {
        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        /*var editEditor = UE.getEditor('edit_editor', {
            autoHeight: false
        });*/
        var contentEditor = UE.getEditor('edit_content_editor', {
            autoHeight: false
        });
        contentEditor.ready(function () {
            //设置编辑器的内容
            contentEditor.setContent([[${newsInfo.content}]]);
        });
            //初始化图片上传按钮
            initFileUpload('#edit_imageUrl', 'imageUrl');
            //显示预览图片
            imgPreview('#edit_imageUrl', 'imageUrl', [[${newsInfo.imageUrl}]]);
    });

    function edit() {
        doRequest({
            formId: '#form_edit',
            url: '/api/newsInfos/edit',
            type: 'PATCH',
            extraData: {
                content: UE.getEditor('edit_content_editor').getContent(),
    }
    });
    }

    function clearForm() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    /*]]>*/
</script>
</body>
</html>